package com.wjk.kylin.rpc.core.config;

import com.wjk.kylin.rpc.core.invoker.route.LoadBalance;
import com.wjk.kylin.rpc.core.registry.RegistryTypeEnum;
import com.wjk.kylin.rpc.core.serialize.Serializer;
import org.springframework.boot.context.properties.ConfigurationProperties;

/**
 * @author wjk
 */
@ConfigurationProperties(prefix = "kylin.rpc.consumer")
public class RpcConsumerConfigProperties {
    /**
     * 是否启动rpc 服务消费者，默认不启用
     */
    private boolean enable = false;
    /**
     * 序列化：默认hessian
     */
    private Serializer.Algorithm serializer = Serializer.Algorithm.Hessian;
    /**
     * 服务提供者和服务消费者token验证，默认不使用
     */
    private String accessToken;
    /**
     * 注册中心，默认地址127.0.0.1：2181
     * 默认使用zookeeper
     */
    private Registry registry = new Registry();

    /**
     * 负载均衡，服务消费者全局设置 - 暂不支持全局设置
     */
    private LoadBalance.Route loadBalance = LoadBalance.Route.Round;

//    /**
//     * 调用方式
//     */
//    private CallType callType = CallType.SYNC;
//
//    public CallType getCallType() {
//        return callType;
//    }
//
//    public void setCallType(CallType callType) {
//        this.callType = callType;
//    }

    public LoadBalance.Route getLoadBalance() {
        return loadBalance;
    }

    public void setLoadBalance(LoadBalance.Route loadBalance) {
        this.loadBalance = loadBalance;
    }

    public String getAccessToken() {
        return accessToken;
    }

    public void setAccessToken(String accessToken) {
        this.accessToken = accessToken;
    }

    public Boolean getEnable() {
        return enable;
    }

    public void setEnable(Boolean enable) {
        this.enable = enable;
    }


    public Serializer.Algorithm getSerializer() {
        return serializer;
    }

    public void setSerializer(Serializer.Algorithm serializer) {
        this.serializer = serializer;
    }

    public Registry getRegistry() {
        return registry;
    }

    public void setRegistry(Registry registry) {
        this.registry = registry;
    }

    public static class Registry {
        private String address = "127.0.0.1:2181";
        private RegistryTypeEnum type = RegistryTypeEnum.ZOOKEEPER;

        public String getAddress() {
            return address;
        }

        public void setAddress(String address) {
            this.address = address;
        }

        public RegistryTypeEnum getType() {
            return type;
        }

        public void setType(RegistryTypeEnum type) {
            this.type = type;
        }
    }
}
